package ncc.wolfcode.luowowo.mgrsite.controller;


import cn.wolfcode.luowowo.article.domain.Strategy;
import cn.wolfcode.luowowo.article.query.StrategyQuery;
import cn.wolfcode.luowowo.article.service.IStrategyService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/strategy")
@Controller
public class StrategyController {
    @Reference
    private IStrategyService strategyService;

    @RequestMapping("/list")
    public String list(Model model,@ModelAttribute("qo") StrategyQuery qo) {
        PageInfo pageInfo = strategyService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "strategy/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public AjaxResult saveOrUpdate(Strategy strategy) {
        strategyService.saveOrUpdate(strategy);
        return AjaxResult.SUCCESS;
    }
}
